{extend name="public/base"/}
{block name="style"}
{/block}
{block name="content"}
    <div class="data-list" data-url="{:url('index')}">
        <form class="layui-form inline-form">
            <div class="pull-left">
                <div class="layui-inline">
                    <input class="layui-input" autocomplete="off" name="name" placeholder="品牌名">
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm layui-btn-normal search"><i class="layui-icon layui-icon-search"></i></button>
                </div>
                <input type="hidden" id="upload-file">
            </div>
            <div class="pull-right">
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-normal layui-btn-sm ajax-form" data-url="{:url('add')}"><i class="layui-icon layui-icon-add-circle"></i> 新增</button>
                </div>
            </div>
        </form>
        <div class="data">
            <p><i class="fa fa-spinner fa-spin"></i> 加载中...</p>
        </div>
    </div>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use(['upload'], function()
    {
        var upload = layui.upload;
        upload.render({
            elem: '#upload-file' //绑定元素
            ,url: '{:url("file/upload",["type"=>"image"])}' //上传接口
            , accept: 'images' //普通文件
            , exts: 'jpg|jpeg|png' // 指定类型
            , before: function (obj) {
                layer.load(0, {shade: false});
            }
            ,done: function(response)
            {
                layer.closeAll('loading');
                if (response.code == 1)
                {
                    $("#brand-logo-path").val(response.data.src);
                    $("#brand-logo-img").attr("src", response.data.src).show();
                }
            }
        });

        $("body").on("click", "#logo-upload-btn", function()
        {
            $("#upload-file").click();
        });
    });
</script>
{/block}